Skip to content

feat: add RawAesKeyring for bring-your-own-key encryption - #202

Open
pchikoian wants to merge 1 commit into
aws:mainfrom
pchikoian:add-raw-aes-keyring
Open

feat: add RawAesKeyring for bring-your-own-key encryption#202
pchikoian wants to merge 1 commit into
aws:mainfrom
pchikoian:add-raw-aes-keyring

Conversation

@pchikoian

Copy link
Copy Markdown

Summary

  • Adds RawAesKeyring, a keyring that wraps data keys locally with a caller-supplied AES key (16/24/32 bytes) using AES-GCM, with no dependency on AWS KMS. Uses the AES/GCM wrapping-algorithm identifier already reserved for this purpose in the object metadata format (V3 code "02").
  • Fixes PutEncryptedObjectPipeline and MultipartUploadPipeline, which hardcoded the stored wrapping-algorithm metadata to "kms+context"/"12" regardless of which keyring produced the data key. This silently discarded non-KMS keyrings' wrap-algorithm identifiers and prevented any custom keyring (including this new one) from round-tripping through put_object/get_object.

Test plan

  • New unit tests in test/test_raw_aes_keyring.py covering init validation, encrypt/decrypt round-trip, wrong wrapping key, mismatched key name, mismatched encryption context, tampered ciphertext (23 tests)
  • Manual end-to-end round trip through PutEncryptedObjectPipeline/GetEncryptedObjectPipeline for both the default V3 (key-committing) and V2 algorithm suites
  • Full existing test suite passes (342 passed)
  • ruff check / ruff format --check clean

🤖 Generated with Claude Code

Adds a keyring that wraps data keys locally with a caller-supplied AES
key (16/24/32 bytes) using AES-GCM, with no dependency on AWS KMS. Uses
the "AES/GCM" wrapping-algorithm identifier already reserved for this
purpose in the object metadata format (V3 code "02").

Also fixes PutEncryptedObjectPipeline and MultipartUploadPipeline, which
hardcoded the stored wrapping-algorithm metadata to "kms+context"/"12"
regardless of which keyring produced the data key. This silently
discarded non-KMS keyrings' wrap-algorithm identifiers and prevented any
custom keyring from round-tripping through put_object/get_object.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant